package cosc617_blackteam;

import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author sherbahadur This class contain Table clas with the enum arrays of
 * table that checks whether the given table is empty or full and if it is empty
 * than checks the size of the party and assigns that particular table to that
 * party and puts a flag on the occupied table and also return the number of
 * empty seats in a given table so that a stranger can also accommodate
 */
public class TableCollections implements Iterable<Table>{

	private IdGenerator idGenerator;
	private ArrayList<Table>tableList;

	public TableCollections(){
		tableList = new ArrayList<Table>();
		idGenerator = new IdGenerator(0);
	}
	/**
	 * This constructor isn't doing what I think it was meant to do.
	 * @param
	 */
	public TableCollections(ArrayList <Table> listOfTables){
		this();
		for(Table table : listOfTables)
			addTable(table);

	}


	public void addTable(Table table){
		table.setID(idGenerator.getNextId());
		tableList.add(table);
	}

	public int getNumTables(){
		return tableList.size();
	}
	public void generateDefaultTableList(){
		Table table;
		tableList.clear();
		table = new Table(2,0);
		addTable(table);
		table = new Table(2,1);
		addTable(table);
		table = new Table(2,2);
		addTable(table);
		table = new Table(2,3);
		addTable(table);
		table = new Table(4,4);
		addTable(table);
		table = new Table(4,5);
		addTable(table);
		table = new Table(4,6);
		addTable(table);
		table = new Table(4,7);
		addTable(table);
		table = new Table(4,8);
		addTable(table);
		table = new Table(6,9);
		addTable(table);
		table = new Table(6,10);
		addTable(table);
		table = new Table(6,11);
		addTable(table);
		table = new Table(6,12);
		addTable(table);
	}
	@Override
	public Iterator<Table> iterator() {
		// TODO Auto-generated method stub
		return new DefaultTableIterator(tableList);
	}

	public Iterator<Table> getEmptyTableIterator(){
		return new EmptyTableIterator(tableList);
	}

	public void removeTable (Table table){
		tableList.remove(table);
	}
}
